package com.ofek.eventos;

import android.content.Intent;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.LocalBroadcastManager;

import com.ofek.eventos.EventsFragment.EventsFragmentController;
import com.ofek.eventos.ToolController.ToolListener;
import com.ofek.eventos.db.EventosSyncService;
import com.ofek.eventos.db.datatypes.EventData;

public abstract class EventsFragmentActivity extends FragmentActivity implements EventsFragmentController, ToolListener {
	@Override
	public void onEventPressed(final EventData event) {
		EventosAndroidUtils.startFormActivity(this, FormActivity.ACTION_FORM_EVENT, event);
	}

	protected void changeFrgment(final Fragment fragment) {
		final FragmentManager fragmentManager = getSupportFragmentManager();
		final FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
		fragmentTransaction.replace(R.id.container, fragment);
		fragmentTransaction.commit();
	}
	@Override
	public void onSyncClicked() { 
		LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent(EventosSyncService.REQUEST_SYNC));
	}
}
